package javacore.fundamentals;

class Person {
	private String name;

	public Person(String name) {
		this.name = name;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

}

public class PassingArgDemo {

	void changeName(Person person, String nameToChange) {
		person.setName(nameToChange);
	}

	public static void main(String[] args) {
		/* Reading n person name from arg */
		int numberOfPerson = args.length;
		System.out.println("We have " + numberOfPerson + " person(people):");
		for (int i = 0; i < numberOfPerson; i++)
			System.out.println("\t- " + args[i]);

		/* Changing name a person */
		Person p = new Person("Unknow");
		System.out.println("I dont know this person: " + p.getName());
		new PassingArgDemo().changeName(p, "Tran Ngoc Chau");
		System.out.println("Ah this is my name: " + p.getName());
	}
}
